/**
 * @file type.h
 * @author cytus
 * @brief
 * @version 0.1
 * @date 2022-05-31
 * @date 2022-07-10
 *
 * @note 增加引擎内置类型
 * @note 添加定义宏以使用基本类型
 *
 * @copyright Copyright (c) 2022
 *
 */

#ifndef _TYPE_H_
#define _TYPE_H_

#include "preclude.h"
#include "platform.h"

//基元类型

using int8 = int8_t;
using int16 = int16_t;
using int32 = int32_t;
using int64 = int64_t;

using uint8 = uint8_t;
using uint16 = uint16_t;
using uint32 = uint32_t;
using uint64 = uint64_t;

using char8 = char;
using char16 = char16_t;
using char32 = char32_t;
using unichar = wchar_t;

using uchar8 = unsigned char;
using uchar16 = char16_t;
using uchar32 = char32_t;

using float32 = float;
using float64 = double;
using float128 = long double;

using uBoolean = bool;
using uHandle = void *;
using uULL = unsigned long long;

//基本类型

#ifdef _UENCODE_UNICODE_
using uString = std::wstring;
#define UTEXT(x) L## #x
#elif defined(_UENCODE_UTF8_)
using uString = std::string;
#define UTEXT(x) x
#else
using uString = std::string;
#define UTEXT(x) x
#endif

//=============================================================

template <typename T>
struct uPoint
{
    T X;
    T Y;
};
template <typename T>
struct uRect
{
    T X;
    T Y;
    T W;
    T H;
};
template <typename T>
struct uRGB
{
    T R;
    T G;
    T B;
};
template <typename T>
struct uRGBA
{
    T R;
    T G;
    T B;
    T A;
};

//函数指针类型
//用于包装一个具有通用类型的函数指针
template<typename FuncType>
struct TFuncPtrType;
template <typename RetType, typename... ArgTypes>
struct TFuncPtrType<RetType(ArgTypes...)>
{
    typedef RetType (*Type)(ArgTypes...);
};

//类成员函数指针类型
//用于包装一个具有通用类型的类成员函数指针
template <typename Class, typename FuncType>
struct TMemFuncPtrType;
template <typename Class, typename RetType, typename... ArgTypes>
struct TMemFuncPtrType<Class,RetType(ArgTypes...)>
{
    typedef RetType (Class::*Type)(ArgTypes...);
};

//代理类型
//描述一个代理类型，对象或函数持有此对象可调用其代理的函数
template <typename RetType>
using DelegateFuncType = std::function<RetType()>;

#endif